﻿using System;

namespace Sgr.Domain.Uow
{
    /// <summary>
    /// 工作单元失败事件参数类
    /// </summary>
    public class UnitOfWorkFailedEventArgs : UnitOfWorkEventArgs
    {
        /// <summary>
        /// 获取异常信息
        /// </summary>
        public Exception? Exception { get; }

        /// <summary>
        /// 获取一个值，该值指示工作单元是否已回滚
        /// </summary>
        public bool IsRolledback { get; }

        /// <summary>
        /// 初始化 <see cref="UnitOfWorkFailedEventArgs"/> 类的新实例
        /// </summary>
        /// <param name="unitOfWork">工作单元实例</param>
        /// <param name="exception">异常信息</param>
        /// <param name="isRolledback">是否已回滚</param>
        public UnitOfWorkFailedEventArgs(IUnitOfWork unitOfWork, Exception? exception, bool isRolledback)
            : base(unitOfWork)
        {
            Exception = exception;
            IsRolledback = isRolledback;
        }
    }
}